package cn.xinfei.xdecision.common.service.component.dependency;

import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.PageResultNew;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.common.requestParam.AssemblyRuleCodeReq;
import cn.xinfei.xdecision.common.model.component.dependency.EngineNodeComponentRel;
import cn.xinfei.xdecision.common.model.component.dependency.resp.DecisionComponentDependencyResp;
import cn.xinfei.xdecision.common.model.datax.datainterface.v2.VariableVO;
import cn.xinfei.xdecision.common.model.enginex.po.EngineVersion;
import cn.xinfei.xdecision.common.service.enginex.EngineNodeService;
import cn.xinfei.xdecision.common.service.enginex.EngineVersionService;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

/**
 * 组件中心依赖关系
 */
public interface EngineNodeComponentRelService extends IService<EngineNodeComponentRel> {

    /**
     * 通过组件code查询全部依赖关系，分页
     *
     * @param assemblyRuleCodeReq 组件中心规则code
     * @return {@link DecisionComponentDependencyResp 依赖决策流关系返回值}
     */
    ResponseEntityDto<PageResultNew<DecisionComponentDependencyResp>> getRelByComponentCode(AssemblyRuleCodeReq assemblyRuleCodeReq);

    /**
     * 通过组件code查询全部依赖关系
     *
     * @param componentCodes 组件中心规则codes
     * @return {@link EngineNodeComponentRel 依赖关系}
     */
    List<EngineNodeComponentRel> getRelByComponentCode(List<String> componentCodes);

    /**
     * 保存依赖关系
     *
     * @see EngineNodeService#updateNodeInfo(cn.xinfei.xdecision.common.model.decisionflow.NodeJsonUpdateReqVo)
     * @see EngineNodeService#copy(java.lang.Long)
     * @see EngineVersionService#copyAndCreateVersion(cn.xinfei.xdecision.common.model.enginex.vo.EngineVersionReqVo)
     */
    Boolean saveOrUpdateRel(EngineNodeComponentRel engineNodeComponentRel);

    /**
     * 通过变量code集合查询依赖关系，每批最大200个
     *
     * @return {@link DecisionComponentDependencyResp 依赖决策流关系返回值}
     */
    ResponseEntityDto<PageResult<List<DecisionComponentDependencyResp>, EngineNodeComponentRel>> getRelByVarCode(AssemblyRuleCodeReq assemblyRuleCodeReq);

    /**
     * 批量删除依赖关系
     *
     * @param list 依赖关系
     * @see EngineNodeService#removeNode(java.lang.Long)
     * @see EngineVersionService#clear(cn.xinfei.xdecision.common.model.enginex.vo.EngineVersionReqVo)
     */
    Integer removeRel(List<EngineNodeComponentRel> list);


    /**
     * 通过引擎版本id查询变量集合
     *
     * @param engineVersion 引擎版本
     */
    List<VariableVO> searchVariablesByEngineVersionId(EngineVersion engineVersion);

    /**
     * 查询子引擎信息
     *
     * @param engineNodes   引擎code
     * @param componentType 引擎类型
     */
    List<DecisionComponentDependencyResp> listByEngineNodeCodes(List<String> engineNodes, Integer componentType, Integer status);
}
